import request from '@/utils/request'

// 查询活动报名列表
export function listEnrollment(query) {
  return request({
    url: '/secondclass/enrollment/list',
    method: 'get',
    params: query
  })
}

// 查询活动报名详细
export function getEnrollment(enrollmentId) {
  return request({
    url: '/secondclass/enrollment/' + enrollmentId,
    method: 'get'
  })
}

// 查询活动报名人数
export function countEnrollment(activityId) {
  return request({
    url: '/secondclass/enrollment/count/' + activityId,
    method: 'get'
  })
}

// 查询用户是否已报名活动
export function checkUserEnrolled(activityId, userId) {
  return request({
    url: '/secondclass/enrollment/check',
    method: 'get',
    params: {
      activityId: activityId,
      userId: userId
    }
  })
}

// 新增活动报名
export function addEnrollment(data) {
  return request({
    url: '/secondclass/enrollment',
    method: 'post',
    data: data
  })
}

// 修改活动报名
export function updateEnrollment(data) {
  return request({
    url: '/secondclass/enrollment',
    method: 'put',
    data: data
  })
}

// 更新活动报名状态
export function updateEnrollmentStatus(enrollmentId, status) {
  return request({
    url: '/secondclass/enrollment/status/' + enrollmentId,
    method: 'put',
    params: { status: status }
  })
}

// 更新活动报名签到状态
export function signInEnrollment(enrollmentId) {
  return request({
    url: '/secondclass/enrollment/signin/' + enrollmentId,
    method: 'put'
  })
}

// 批量签到活动报名
export function batchSignIn(enrollmentIds) {
  return request({
    url: '/secondclass/enrollment/batchSignin',
    method: 'put',
    data: enrollmentIds
  })
}

// 删除活动报名
export function delEnrollment(enrollmentId) {
  return request({
    url: '/secondclass/enrollment/' + enrollmentId,
    method: 'delete'
  })
}
